<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>用户管理系统</title>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/styles.css">
</head>
<body>
<div class="header">
    <span class="header-title">用户管理系统</span>
    <span class="header-right">
          <span class="welcome-text">  欢迎<c:out value="${sessionScope.user.username}" default="游客"/>,</span>
          <span><a class="login-link" href="${pageContext.request.contextPath}/logout">注销</a></span>
        </span>
</div>
<div class="sidebar">
    <div class="sidebar-header">
        <img src="${pageContext.request.contextPath}/images/bookshelf.png" alt="Library Icon">
    </div>
    <a href="#" class="level-1">用户管理</a>
    <a href="${pageContext.request.contextPath}/books?action=list" class="level-2">用户列表</a>
    <a href="${pageContext.request.contextPath}/books?action=showForm" class="level-2">添加用户</a>
    <a href="#" class="level-1">系统管理</a>
    <a href="${pageContext.request.contextPath}/system?action=log" class="level-2">操作日志</a>
    <a href="#" class="level-1">用户中心</a>
    <a href="${pageContext.request.contextPath}/user?action=changePassword" class="level-2">修改密码</a>
</div>
<div class="main-content">
    <h2>${book != null ? '编辑用户' : '添加用户'}</h2>
    <form action="${pageContext.request.contextPath}/books" method="post">
        <input type="hidden" name="action" value="${book != null ? 'update' : 'insert'}">
        <input type="hidden" name="id" value="${book.id}">

        <div class="form-group">
            <label for="title">书名:</label>
            <input type="text" id="title" name="title" value="${book.title}" required>
        </div>
        <div class="form-group">
            <label for="author">作者:</label>
            <input type="text" id="author" name="author" value="${book.author}" required>
        </div>
        <div class="form-group">
            <label for="isbn">书号ISBN:</label>
            <input type="text" id="isbn" name="isbn" value="${book.isbn}" required>
        </div>
        <div class="form-group">
            <label for="publisher">出版社:</label>
            <input type="text" id="publisher" name="publisher" value="${book.publisher}" required>
        </div>
        <div class="form-group">
            <label for="publicationYear">出版年份:</label>
            <input type="number" id="publicationYear" name="publicationYear" value="${book.publicationYear}" required>
        </div>
        <div class="form-group">
            <label for="language">语言:</label>
            <select id="language" name="language" required>
                <option value="中文" ${book.language == '中文' ? 'selected' : ''}>中文</option>
                <option value="英文" ${book.language == '英文' ? 'selected' : ''}>英文</option>
                <option value="法文" ${book.language == '法文' ? 'selected' : ''}>法文</option>
                <option value="日文" ${book.language == '日文' ? 'selected' : ''}>日文</option>
                <option value="德文" ${book.language == '德文' ? 'selected' : ''}>德文</option>
            </select>
        </div>
        <div class="form-group">
            <label for="genre">类别:</label>
            <select id="genre" name="genre" required>
                <option value="政治讽刺" ${book.genre == '政治讽刺' ? 'selected' : ''}>政治讽刺</option>
                <option value="文学" ${book.genre == '文学' ? 'selected' : ''}>文学</option>
                <option value="奇幻" ${book.genre == '奇幻' ? 'selected' : ''}>奇幻</option>
                <option value="悬疑" ${book.genre == '悬疑' ? 'selected' : ''}>悬疑</option>
                <option value="科幻" ${book.genre == '科幻' ? 'selected' : ''}>科幻</option>
                <option value="科学技术" ${book.genre == '科学技术' ? 'selected' : ''}>科学技术</option>
            </select>
        </div>
        <div class="form-group">
            <label for="location">馆藏位置:</label>
            <select id="location" name="location" required>
                <option value="中文理科1室" ${book.location == '理科1室' ? 'selected' : ''}>理科1室</option>
                <option value="理科2室" ${book.location == '理科2室' ? 'selected' : ''}>理科2室</option>
                <option value="文科1室" ${book.location == '文科1室' ? 'selected' : ''}>文科1室</option>
                <option value="文科2室" ${book.location == '文科2室' ? 'selected' : ''}>文科2室</option>
                <option value="珍藏室" ${book.location == '珍藏室' ? 'selected' : ''}>珍藏室</option>
            </select>
        </div>
        <div class="form-group">
            <label for="status">用户状态:</label>
            <select id="status" name="status" required>
                <option value="1" ${book.status == 1 ? 'selected' : ''}>在馆</option>
                <option value="2" ${book.status == 2 ? 'selected' : ''}>外借</option>
                <option value="3" ${book.status == 3 ? 'selected' : ''}>未上架</option>
            </select>
        </div>
        <div class="form-group full-width">
            <label for="description">用户简介:</label>
            <textarea id="description" name="description">${book.description}</textarea>
        </div>
        <div class="form-group submit">
            <input type="submit" value="${book != null ? '更新用户' : '添加用户'}">
        </div>
    </form>
    <p></p> @edu XXX大学计算机学院 班级:xxx, 学号:xx, 姓名:xxx <p></p>
</div>
</div>
</body>
</html>
